Repository navigation
feat(Experiments): Get experiment flags, and track events and exposures - #83
Conversation
Its entry in Flagsmith/sdk-spec's compatibility matrix at v0.7.1: `core or events or local-evaluation`.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Merging this PR will not alter performance
Comparing Footnotes
|
Implements the experimentation features the SDK spec's `events` scenarios require, run from SDK spec v0.7.1: - `enable_events` starts an event processor that buffers events and sends them to Flagsmith's events API in batches. - `get_experiment_flag` resolves a flag for an identity and records a `$flag_exposure` when the identity is enrolled in a running experiment. - `track_event` and `track_exposure_event` record events directly. - `Flag` exposes the `variant` and `experiment` served by remote identity evaluation. Re-applied from f28b98d on top of flag dependency evaluation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The SDK spec was failing because v0.7.1 runs this SDK's Changes
The re-application had two conflicts, in Checked locally: Review effort: 3/5 |
getExperimentFlag, trackEvent and trackExposure methods
gagantrivedi
left a comment
There was a problem hiding this comment.
update the pr description and title based on what's implemented in the pull request
getExperimentFlag, trackEvent and trackExposure methods
Both are done. No code changed, so there is no new commit.
|
An offline client still started the event processor when events were enabled, so tracking and exposure events reached the events API. In offline mode the processor is no longer started, and experiment flags and event tracking return an error that names offline mode, as the Python SDK does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_experiment_flag sent its exposure straight to the event processor, skipping the identifier check of track_exposure_event, and requested flags for an empty identity. It now returns an error before any request, as track_exposure_event does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An exposure event requires an identifier, yet it was an optional field of EventOptions, so a missing one was only caught at runtime. The identifier is now an argument: required by track_exposure_event, and optional for track_event, whose events need not be about an identity. EventOptions keeps the optional value, traits and metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 I have created a release *beep* *boop* --- ## [3.3.0](v3.2.0...v3.3.0) (2026-11-10) ### Features * **Experiments:** Get experiment flags, and track events and exposures ([#83](#83)) ([23b6a53](23b6a53)) ### Other * Let Renovate keep updating spec bumps the webhook handler commits to ([#79](#79)) ([de1d8e8](de1d8e8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Lets Rust applications run experiments with Flagsmith. An application can get an identity's experiment flag, which records which variant the identity was exposed to. It can also send tracking events, such as conversions, to Flagsmith's events API. This implements SDK spec v0.7.1, and its spec run now includes the
eventsscenarios.Changes
enable_events). Events are buffered and sent to Flagsmith's events API in batches: on a timer, when the buffer fills, onflush_events, and when the client is dropped. The events API URL, flush interval and buffer size can be configured. Offline clients send no events.get_experiment_flagreturns an identity's flag, and requires an identifier. When the identity is enrolled in a running experiment, it also records a$flag_exposureevent for the variant served, with the identity's traits.track_eventrecords an application event, with an optional identity, value and metadata. Names starting with$are reserved.track_exposure_eventrecords an exposure for a variant evaluated elsewhere. It requires an identity.variantserved and the runningexperiment.core,eventsandlocal-evaluationscenarios. Empty string flag values, new in v0.7.1, already worked.Contributes to Flagsmith/sdk-spec#13
Review effort: 3/5